﻿function GetUnicArray(inpurArray) {
    var i = inpurArray.length, result = [];
    inpurArray.sort(function (a, b) {return b - a;});
    while (i--) {
        if (result.join().search(inpurArray[i] + '\\b') == '-1') {
            result.push(inpurArray[i]);
        }
    }
    return result;
}

function stringFormat(args) {
    var str = this.toString();
    var searchIndex = 0;
    var counter = 0;

    do {
        searchIndex = str.indexOf("{%}", searchIndex);
        if (searchIndex > -1 && args[counter]) {
            str = str.substring(0, searchIndex) + args[counter] + str.substring(searchIndex + 3, str.length);
            searchIndex += args[counter++].length;
        } else {
            break;
        }
    } while (true);

    return str;
};
String.prototype.format = stringFormat;

// Проверка, является ли нажатие клавиши мыши правым кликом.
function isRightClick(event) {
    var rightclick = false;
    event = event || window.event;
    if (event.which) {
        rightclick = (event.which == 3); // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
    } else if (event.button) {
        rightclick = (event.button == 2); // IE, Opera
    }
    return rightclick;
}